package com.redrose.videodemo.okhttpustil;

import com.redrose.videodemo.utils.ConstantUtil;
import com.redrose.videodemo.utils.SimpleUtils;
import com.zhy.http.okhttp.callback.Callback;

import java.lang.reflect.Type;

import okhttp3.Response;


public abstract class ResponseCallback<T> extends Callback<T> {

    private Type mType;

    public ResponseCallback() {
        mType = SimpleUtils.getSuperclassTypeParameter(getClass());
    }

    @Override
    public T parseNetworkResponse(Response response, int id) throws Exception {
        String content = response.body().string();
        return ConstantUtil.mGson.fromJson(content, mType);
    }


}
